using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using au.Swindles.CustomerEnquiryService.ObjectLayer;
using System.Collections.Generic;
using au.Swindles.CustomerEnquiryService.AdapterLayer;

namespace au.Swindles.CustomerEnquiryService.BLLayer
{
    public static class BLCustomer
    {
        public static Customer getCustomer(int pCustomerID, string pCustomerName)
        {
            Customer customer = null;
            try
            {
                List<Customer> customerlist = CustomerAdapter.getCustomerList();
                
                if (customerlist != null)
                {
                    foreach (Customer obj in customerlist)
                    {
                        if (obj.CustomerID == pCustomerID
                            && obj.CustomerName == pCustomerName)
                        {
                            customer = obj;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return customer;
        }

        public static Customer getCustomer(int pCustomerID)
        {
            Customer customer = null;
            try
            {
                List<Customer> customerlist = CustomerAdapter.getCustomerList();

                if (customerlist != null)
                {
                    foreach (Customer obj in customerlist)
                    {
                        if (obj.CustomerID == pCustomerID)
                        {
                            customer = obj;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return customer;
        }

        public static bool updateCustomer(Customer pCustomer)
        {
            try
            {
                CustomerAdapter.updateCustomer(pCustomer);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
            
        }
    }
}
